//
//  JZFit.swift
//  
//
//  Created by S JZ on 2024/2/1.
//

import Foundation

public extension Int {
    public var fit: Int { return self * Int(JZDefine.fit) }
}

public extension Float {
    public var fit: Float { return self * Float(JZDefine.fit) }
}

public extension Double {
    public var fit: Double { return self * Double(JZDefine.fit) }
}

public extension CGFloat {
    public var fit: CGFloat { return self * JZDefine.fit }
}

public extension CGSize {
    public var fit: CGSize {
        var width = self.width * JZDefine.fit
        if self.width == JZDefine.screenWidth {
            width = self.width
        }
        
        var height = self.height * JZDefine.fit
        if self.height == JZDefine.screenHeight {
            height = self.height
        }
        
        return CGSize(width: width, height: height)
    }
}

public extension CGRect {
    public var fit: CGRect {
        let x = self.origin.x * JZDefine.fit
        let y = self.origin.y * JZDefine.fit
        
        var width = self.size.width * JZDefine.fit
        if self.size.width == JZDefine.screenWidth {
            width = self.size.width
        }
        
        var height = self.size.height * JZDefine.fit
        if self.size.height == JZDefine.screenHeight {
            height = self.size.height
        }
        
        return CGRect(x: x, y: y, width: width, height: height)
    }
}


